//
//  ScribbleThumbnailCell.m
//  Test
//
//  Created by 杨德龙 on 2017/11/28.
//  Copyright © 2017年 ___杨德龙___. All rights reserved.
//

#import "ScribbleThumbnailCell.h"

@implementation ScribbleThumbnailCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setBackgroundColor:[UIColor clearColor]];
    }
    return self;
}


+ (NSInteger)numberOfPlaceHolders
{
    return 3;
}

// 实际上这种 重复移除 和 添加的 会造成很大的 性能消耗
- (void)addThumbnailView:(UIView *)thumbnailView atIndex:(NSInteger)index
{
    if (index == 0) {
        for (UIView *view in  [[self contentView] subviews]) {
            [view  removeFromSuperview];
        }
    }
    
    if (index < [ScribbleThumbnailCell numberOfPlaceHolders]) {
        CGFloat x = index * 90 + (index + 1)*12;
        CGFloat y = 10;
        CGFloat width = 90;
        CGFloat height = 130;
        [thumbnailView setFrame:CGRectMake(x, y, width, height)];
        [self.contentView addSubview:thumbnailView];
    }
    
}






@end


































